using System;
using UnityEngine;


public class ItemNetHandler : Singleton< ItemNetHandler > 
{
	void Awake ()
	{
		if ( mInstance == null )
		{
			mInstance = this;
			initHandler();
		}
		
	}

	public ItemNetHandler ()
	{

	}

	
	public void initHandler()
	{
		GameSocketManager.instance.regeditMsg( (int)GameNetMessage.MsgType._MSG_RECV_USE_ITEM , recvMsgUseItem , typeof( GameNetMessage.RECV_MSG_USE_ITEM ) );

	}

	public void sendDropItem( int i1 , int i2 )
	{
		GameNetMessage.SEND_MSG_DROP_EQUIP msg = new GameNetMessage.SEND_MSG_DROP_EQUIP();
		msg.initNetHead();

		msg.i1 = (short)i1;
		msg.i2 = (short)i2;

		GameSocketManager.instance.sendMsg( msg );
	}
	
	public void sendSwitchItem( int i1 , int i2 )
	{
		GameNetMessage.SEND_MSG_SWITCH_ITEM msg = new GameNetMessage.SEND_MSG_SWITCH_ITEM();
		msg.initNetHead();

		msg.i1 = (short)i1;
		msg.i2 = (short)i2;
		
		GameSocketManager.instance.sendMsg( msg );
	}
	
	public void sendSwitchEquip( int i1 , int i2 )
	{
		GameNetMessage.SEND_MSG_DROP_EQUIP msg = new GameNetMessage.SEND_MSG_DROP_EQUIP();
		msg.initNetHead();

		msg.i1 = (short)i1;
		msg.i2 = (short)i2;
		
		GameSocketManager.instance.sendMsg( msg );
	}
	
	public void sendUseItem( int i , int p , int t )
	{
		GameNetMessage.SEND_MSG_USE_ITEM msg = new GameNetMessage.SEND_MSG_USE_ITEM();
		msg.initNetHead();

		msg.i = (short)i;
		msg.p = p;
		msg.t = (short)t;
		
		GameSocketManager.instance.sendMsg( msg );
	}

	public void recvMsgUseItem( GameNetMessage.NetMsgInterface head )
	{
		GameNetMessage.RECV_MSG_USE_ITEM msg = ( GameNetMessage.RECV_MSG_USE_ITEM )head;
		
		Debug.Log( "recv msg " +  msg.head.type ); 
	}


}


